﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;

namespace Drifting.Graphics.PhysicalObjects.Others
{
    public class ISS : PhysicalObject
    {
        public ISS(Game1 game)
        {
            Body = game.Content.Load<Model>("models\\SpaceStationSkins\\SpaceStation_skin_full");
            Body_AbsoluteMatrix = new Matrix[Body.Bones.Count];
            Body.CopyAbsoluteBoneTransformsTo(Body_AbsoluteMatrix);

            body_scale = 0.00172f;    // this is 1/10 scale.  0.023855f is 1:1
            m_calibration = Matrix.CreateRotationY(0) * Matrix.CreateTranslation(0, 0, 0);
        }

        override public void Draw(Matrix camera, Matrix projection)
        {
            foreach (ModelMesh mesh in Body.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    
                    effect.View = camera;
                    effect.Projection = projection;
                    effect.World =

                        Body_AbsoluteMatrix[mesh.ParentBone.Index] *

                        Matrix.CreateScale(body_scale) *

                        m_calibration *

                        m_config;

                    // e.g. 
                    //Matrix.CreateRotationY((float)Math.PI/4) *  
                    //Matrix.CreateTranslation(1,0,4);

                }
                mesh.Draw();
            }
        }
    }
}
